package com.ims.core.doc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ims.common.annotation.Log;
import com.ims.common.core.controller.BaseController;
import com.ims.common.core.domain.AjaxResult;
import com.ims.common.enums.BusinessType;
import com.ims.core.doc.domain.TInNonInvoice;
import com.ims.core.doc.service.ITInNonInvoiceService;
import com.ims.common.utils.poi.ExcelUtil;
import com.ims.common.core.page.TableDataInfo;

/**
 * 进项非增值发票Controller
 *
 * @author IMS
 * @date 2024-11-20
 */
@RestController
@RequestMapping("/doc/innoninvoice")
public class TInNonInvoiceController extends BaseController
{
    @Autowired
    private ITInNonInvoiceService tInNonInvoiceService;

    /**
     * 查询进项非增值发票列表
     */
    @PreAuthorize("@ss.hasPermi('doc:innoninvoice:list')")
    @GetMapping("/list")
    public TableDataInfo list(TInNonInvoice tInNonInvoice)
    {
        startPage();
        List<TInNonInvoice> list = tInNonInvoiceService.selectTInNonInvoiceList(tInNonInvoice);
        return getDataTable(list);
    }

    /**
     * 导出进项非增值发票列表
     */
    @PreAuthorize("@ss.hasPermi('doc:innoninvoice:export')")
    @Log(title = "进项非增值发票", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TInNonInvoice tInNonInvoice)
    {
        List<TInNonInvoice> list = tInNonInvoiceService.selectTInNonInvoiceList(tInNonInvoice);
        ExcelUtil<TInNonInvoice> util = new ExcelUtil<TInNonInvoice>(TInNonInvoice.class);
        util.exportExcel(response, list, "进项非增值发票数据");
    }

    /**
     * 获取进项非增值发票详细信息
     */
    @PreAuthorize("@ss.hasPermi('doc:innoninvoice:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tInNonInvoiceService.selectTInNonInvoiceById(id));
    }

    /**
     * 新增进项非增值发票
     */
    @PreAuthorize("@ss.hasPermi('doc:innoninvoice:add')")
    @Log(title = "进项非增值发票", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TInNonInvoice tInNonInvoice)
    {
        return toAjax(tInNonInvoiceService.insertTInNonInvoice(tInNonInvoice));
    }

    /**
     * 修改进项非增值发票
     */
    @PreAuthorize("@ss.hasPermi('doc:innoninvoice:edit')")
    @Log(title = "进项非增值发票", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TInNonInvoice tInNonInvoice)
    {
        return toAjax(tInNonInvoiceService.updateTInNonInvoice(tInNonInvoice));
    }

    /**
     * 删除进项非增值发票
     */
    @PreAuthorize("@ss.hasPermi('doc:innoninvoice:remove')")
    @Log(title = "进项非增值发票", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tInNonInvoiceService.deleteTInNonInvoiceByIds(ids));
    }
}
